package cn.jsj.finance.bank;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 添加现金账记录处理函数
 * @author LI
 *
 */
 public class AddCashAccount extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("添加现金账信息！！！");

		 //获得参数
		 cn.jsj.pojo.TblCashAccount tca=new cn.jsj.pojo.TblCashAccount();

		 String cashBrief=request.getParameter("cashBrief");
		 //换掉换行
		 cashBrief=cashBrief.replaceAll("\n", "，");
		 tca.setCashAccBrief(cashBrief);
		 tca.setCashAccTime(cn.jsj.utils.TimeDispose.transferDate(request.getParameter("cashAccTime").trim()));
		 tca.setIncomeMoney(Integer.parseInt(request.getParameter("cashIncome").trim()));
		 tca.setPayoutMoney(Integer.parseInt(request.getParameter("cashPayout").trim()));

		 //保存银行帐信息
		 cn.jsj.dao.TblCashAccountDAO tcad=new cn.jsj.dao.TblCashAccountDAO();
		 int saveResult=tcad.saveCashInfo(tca);

		 //调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("现金账保存结果-------->"+saveResult);

		 //输出流
		  java.io.PrintWriter out=response.getWriter();
		 //如果保存成功
		 if(saveResult==1){
			 out.println("{message:'保存成功！'}");
		 }else{
			 out.println("{message:'保存失败！'}");
		 }
		 out.flush();
		 out.close();
	}
}